﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Design;
using DevExpress.XtraGrid.Columns;
using ProgNetDxComponents.ExtenderProviders;

namespace ProgNetDxComponents.Design.Designers
{
    internal class LanguageDesigner : DxGridColumnExtenderDesigner
    {
        public override DesignerVerbCollection Verbs
        {
            get
            {
                DesignerVerbCollection v = base.Verbs;
                v.Add(new DesignerVerb("Default Grid Columns Lng Settings", DefaultGridColumns));
                return v;
            }
        }

        private void DefaultGridColumns(object sender, EventArgs e)
        {
            List<GridColumn> columns = GetAllGridColumns();
            if (columns != null && columns.Count > 0)
            {
                LanguageProvider provider = Component as LanguageProvider;
                if (provider != null)
                {
                    foreach (GridColumn c in columns)
                    {
                        provider.GetSettings(c).LngString = c.FieldName;
                    }
                }
            }
        }
    }
}
